<?php
$headImage=$_FILES["headImage"];
var_dump($headImage);

if($headImage){
    if($headImage["error"]==0){
        $rootPath="D:/Users/User/Desktop/php/day04/upload/";
        $newName=time(). mt_rand(1000,9999)."_". $headImage["name"];
        if(move_uploaded_file($headImage["tmp_name"],$rootPath.$newName)){
            echo "<div>上传成功</div>";
            echo "<img style='width:100px;' src='/day04/upload/{$newName}'>";    
        }else{
            echo "<div>文件保存失败</div>";
        }

    }else{
        echo "<div>文件上传失败</div>";
    }
}else{
    echo "<div>没有上传文件</div>";
}
?>